//
//  NetURL.m
//  AirQuality
//
//  Created by Po on 15/5/5.
//  Copyright (c) 2015年 Po. All rights reserved.
//  http://xsscd.xicp.net:5100

#import "NetURL.h"

//登录
#define Login                  @"/smartadmin/login"
//市州站登录
#define cityLogin               @"/smartadmin/login"
//省站获取验证码
#define md3_vertificationCode   @"/smartadmin/getLoginDynamicCode"
//市州站获取验证码
#define cityMd3_vertification  @"/smartadmin/getLoginDynamicCode"
//获取消息状态
#define RMessageStatus        @"/dataShare/getSystemMessages"
//获取消息详情
#define RMessageData          @"/dataShare/getSystemMessageCount"

//AQI等级
#define RAqiRank              @"/smartadmin/home/getAirQualityLevelWithNames"

//获取所有城市站得AQI
#define RJAllCityAQI          @"/publish/getAllCityRealTimeAQIC"
//获取城市实时连接状态
#define RCityConnect          @"/smartadmin/home/getCityStationStatus?stationtypeid=1"
//获取农村实时连接状态
#define RCountryConnect       @"/smartadmin/home/getCityStationStatus?stationtypeid=2"
#define sendMessageToCity    @"/dataShare/sendDownForApp"
//获取所有城市地区
#define RGetAllCityAndStation @"/smartadmin/audit/getStationsWithStatusForApp"
//获取验证码
#define GetLoginDynamicCode  @"/smartadmin/getLoginDynamicCode"
//获取城市状态，timepoint
#define RCheckCityStates      @"/smartadmin/getCitysWithStatus"
//获取站点数据
#define RGetStationData          @"/smartadmin/audit/getStationData"
//获取审核状态说明
#define RCheckStateDescription @"/smartadmin/reason.json"
//审核城市昨天24小时平均
#define RJCheckCityYesterDay24Value @"/smartadmin/statAnalyse/getHourData"
//审核
#define RCheck @"/smartadmin/audit/update"
//提交审核（市州站）
#define RSendCheck @"/smartadmin/audit/sendDownForApp"

//预警获取
#define RGetForecast @"/smartadmin/forecast/getForecast"

//提交预警
#define RSaveForecast @"/smartadmin/forecast/saveForecast"
//预警审核获取
#define RGetForecastAudit @"/smartadmin/forecast/getForecastAudit"
//预警审核提交
#define RSaveForecastAudit @"/smartadmin/forecast/saveForecastAudit"
//站点实时数据
#define StationRealTimeAQIForApp @"/publish/getStationRealTimeAQIForApp"
//站点一个月数据
#define StationOneMonthRealTimeAQIForApp @"/publish/getStationOneMonthRealTimeAQIForApp"
//站点一年 数据
#define Station365DayAQIForApp @"/publish/getStation365DayAQIForApp"
//直管站五分钟数据
#define CStation5mData     @"/CStation/getCStation5mData"

//直管站最近24小时数据
#define CStation24HourData @"/CStation/getCStationHData"

//外部：获取城市实时AQI
#define RGetCityTimeAQI @"/publish/getAllCityRealTimeAQIC"

#define RGetCityDayAQI @"/publish/getAllCityDayAQIC"

static NetURL * netURL = nil;

@interface NetURL ()

@end

@implementation NetURL

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

+ (instancetype)defaultURL
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        netURL = [[self alloc] init];
        
    });
    return netURL;
}

- (void)setUserRank:(BOOL)isProvince cityCode:(NSString *)cityCode
{
    if (isProvince) {
        _headUrl = @"http://www.scnewair.cn:3389";
    } else {
        _headUrl = [NSString stringWithFormat:@"http://www.scnewair.cn:%@",cityCode];
    }
}

- (NSString *)AllCityRealAQI
{
    if ([RJUserData defaultRJUserData].isProvince) {
        return [self url:RJAllCityAQI];
    } else {
        return [self url:[NSString stringWithFormat:@"/publish/getCityInfoC?cityCode=%@",
                          [RJUserData defaultRJUserData].currentCityCode]];
    }
    
}

/**获取最新消息状态*/
- (NSString *)MessageStatus
{
    return [self url:RMessageStatus];
}

/**获取最新消息数据*/
- (NSString *)MessageData
{
    return [self url:RMessageData];
}

/**获取AQI等级分布*/
- (NSString *)AqiRankRange
{
    return [self url:RAqiRank];
}

/**获取城市站点实时连接*/
- (NSString *)CityConnect
{
    if ([RJUserData defaultRJUserData].isProvince) {
        return [self url:RCityConnect];
    } else {
        return [self url:@"/smartadmin/home/getStationStatus?stationType=1"];
    }
}

/**获取农村站点实时连接*/
- (NSString *)CountryConnect
{
    if ([RJUserData defaultRJUserData].isProvince) {
        return [self url:RCountryConnect];
    } else {
        return [self url:@"/smartadmin/home/getStationStatus?stationType=2"];
    }
}
/**登录域名地址*/

- (NSString *)loginUrl:(NSString *)url isProvince:(BOOL)isProvince{
  
    if (isProvince) {
        //@"http://newair.scemc.cn:5100%@"  @"http://xsscd.xicp.net:5100/smartadmin/audit/update" @"http://221.237.179.54:%@"
        return [NSString stringWithFormat:@"http://www.scnewair.cn:3389%@",url];
    }else
        return [NSString stringWithFormat:@"http://www.scnewair.cn:%@",url];
}

/**省站登录接口*/
- (NSString *)userLogin{
  
    return [self loginUrl:Login isProvince:YES];
    
}

/**市州站登录接口*/
- (NSString *)cityUserLogin:(NSString *)cityCode{

    return [self loginUrl:[NSString stringWithFormat:@"%@%@",cityCode,cityLogin] isProvince:NO];
}

/**获取md3VertificationCode*/

- (NSString *)md3VertificationCode{
    
    return [self loginUrl:md3_vertificationCode isProvince:YES];
}

/**城市站获取md3VertificationCode*/
- (NSString *)cityMd3VertificationCode:(NSString *)cityCode{
    
    return [self loginUrl:[NSString stringWithFormat:@"%@%@",cityCode,cityMd3_vertification] isProvince:NO];
}

/**获取所有城市地区*/
- (NSString *)AllCityAndStation
{
    return [self loginUrl:RGetAllCityAndStation isProvince:YES];
//    return [self url:RGetAllCityAndStation];
}
/**获取登陆验证码*/
- (NSString *)getLoginDynamicCode{
    
    return [self url:GetLoginDynamicCode];
}
/**获取城市状态*/
- (NSString *)CheckCityStates
{
    return [self url:RCheckCityStates];
}

- (NSString *)SendMessageToCity
{
    return [self url:sendMessageToCity];
}
/**获取站点数据*/
- (NSString *)stationData
{
    return [self url:RGetStationData];
}

/**获取审核状态说明*/
- (NSString *)CheckStateDescription
{
    return [self url:RCheckStateDescription];
}

- (NSString *)CheckCityYesterDay24Value
{
    return [self url:RJCheckCityYesterDay24Value];
}

/**审核*/
- (NSString *)Check
{
    return [self url:RCheck];
}

/**上传*/
- (NSString *)sendCheck
{
    return [self url:RSendCheck];
}

/**获取预警*/
- (NSString *)GetForecast
{
    return [self url:RGetForecast];
}

/**提交预警（测试）*/
- (NSString *)SaveForecast
{
    return [self url:RSaveForecast];
}

/**获取预警审核*/
- (NSString *)GetForecastAudit
{
    return [self url:RGetForecastAudit];
}

/**提交预警审核（测试）*/
- (NSString *)SaveForecastAudit
{
    return [self url:RSaveForecastAudit];
}

/**获取城市AQI（外部）*/
- (NSString *)GetCityRealTimeAQI
{
    //http://www.scnewair.cn  http://newair.scemc.cn
    return @"http://www.scnewair.cn:3389/publish/getAllCityRealTimeAQIC";
    
}

- (NSString *)GetCity24HourAQI
{
    // @"http://newair.scemc.cn:5100/publish/getCity24HRealTimeAQIC"
    // @"http://192.168.1.119:5100/publish/getCity24HRealTimeAQIC"
    //http://www.scnewair.cn http://newair.scemc.cn
    //折线图
    return   @"http://www.scnewair.cn:3389/publish/getCity24HRealTimeAQIC"
;
}

- (NSString *)GetAllCityAQI
{
    //@"http://newair.scemc.cn:5100/publish/getAllCityDayAQIC"
    // @"http://192.168.1.119:5100/publish/getAllCityDayAQIC"
    return @"http://www.scnewair.cn:3389/publish/getAllCityDayAQIC";
}

- (NSString *)GetWeather
{
    return @"http://apis.baidu.com/apistore/weatherservice/weather";
}

- (NSString *)getDayDataForApp
{
//    @"http://newair.scemc.cn:5100%@" http://192.168.1.119:5100
    return @"http://www.scnewair.cn:3389%@";
}

- (NSString *)GetCStationBasicData
{
    return [self url:CStation5mData];
}

- (NSString *)GetCStation24HourData
{
    return [self url:CStation24HourData];
}

- (NSString *)getStationRealTimeAQIForApp
{
    return [self url:StationRealTimeAQIForApp];
}

- (NSString *)getStationOneMonthRealTimeAQIForApp
{
    return @"http://www.scnewair.cn:3389/publish/getStationOneMonthRealTimeAQIForApp";
}

- (NSString *)getStation365DayAQIForApp
{
    return @"http://www.scnewair.cn:3389/publish/getStation365DayAQIForApp";
}
- (NSString *)Get356DayAQI
{
    return @"http://www.scnewair.cn:3389/publish/getCity365DayAQI";
}
#pragma mark - function
- (NSString *)url:(NSString *)url
{
//    NSString * s = GetStringWith(_headUrl, url);
//    NSLog(@"%@",GetStringWith(_headUrl, url));
    return GetStringWith(_headUrl, url);
}
@end
